#!/bin/sh

#define
srcCanon=/Library/Caches/Canon
srcCUPS=/Library/Caches/Canon/CUPSPS2
src=/Library/Caches/Canon/CUPSPS2/CCPD
dstCanon=/Library/Preferences/Canon
dstCUPS=/Library/Preferences/Canon/CUPSPS2

#make src folder
mkdir -m 777 -p $src
#restore permission
chmod 777 $srcCanon
chmod 777 $srcCUPS
chmod 777 $src

#copy
if [ -e $dstCUPS/ccpd.conf ]
then
cp -fpr $dstCUPS/ccpd.conf $src
fi
#restore permission
chmod 666 $src/ccpd.conf

#delete CUPSxxx folder
if [ -e $dstCUPS ]
then
rm -fr $dstCUPS
fi

#delete .DS_Store in Canon folder
if [ -e $dstCanon/.DS_Store ]
then
rm -fr $dstCanon/.DS_Store
fi

#delete Canon folder
if [ ! -e $dstCanon/* ]
then
rm -fr $dstCanon
fi
